package com.sure.classsystemserver.security.home;

import com.sure.classsystemserver.common.CommonService;
import com.sure.classsystemserver.common.CurrentUser;
import com.sure.classsystemserver.common.Result;
import com.sure.classsystemserver.common.TokenUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("/security/home")
public class HomeAPI {

    @Resource
    private HomeService homeService;

    @Resource
    private CommonService commonService;

    @GetMapping("/menus")
    public Result menus(@RequestHeader("Token") String token){
        CurrentUser currentUser= TokenUtils.getUserInfo(token,commonService);
        List<MenuVO> menuVOList=homeService.getMenus(currentUser);

        return Result.success(menuVOList);
    }
}
